<template>
	<view class="content">
		
		<u-form-item label-width="150" label="原密码"><u-input type="password" v-model="old_pwd" placeholder="请输入原密码" /></u-form-item>
		<u-form-item  label-width="150" label="新密码"><u-input type="password" v-model="ddpwd" placeholder="请输入新密码"/></u-form-item>
		<u-form-item  label-width="150" label="确认密码"><u-input  type="password" v-model="pwd_confirm" placeholder="请输入确认密码" /></u-form-item>

	
	   <u-button type="primary" throttle-time="500" :loading="loading" @click="save">点击修改</u-button>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				obj:{},
				loading:false,
				pwd_confirm:"",
				password:"",
				old_pwd:""
			}
		},
		onLoad:function(){
			this.obj=uni.getStorageSync("user")
		},
		methods:{
			
			save(){
				
			
				    
				
				if (this.old_pwd==""){
					 this.msg("原密码不能为空")
					 return
				}   
						
				
				if (this.ddpwd==""){
					 this.msg("新密码不能为空")
					 return
				} 
				 if (this.pwd_confirm==""){
				 	 this.msg("确认密码不能为空")
				 	 return
				 }  
				this.loading=true
				this.$u.post('password', {
                    id:this.obj.id,
					old_pwd:this.old_pwd,
					password:this.ddpwd,
					pwd_confirm:this.pwd_confirm

					
				}).then(res => {
					this.loading=false
				    if (res.status==1){
						
						 this.msg("更改成功")
						setTimeout(res=>{ 
							uni.removeStorageSync("user")
							this.$u.route("/pages/login/login")
						}, 2000);
						
					}else{
						this.msg(res.msg)
					}
					
				});
			}
		}
	}
</script>

<style>
</style>
